<template>
	<el-select filterable v-bind="$attrs" v-on="$listeners">
		<el-option :key="item.value" :label="item.label" :value="item.value" v-for="item in options"></el-option>
	</el-select>
</template>
<script>
export default {
	props: {
		/**
		 * 获取分页数据的方法
		 */
		fetchFunction: {
			required: true,
			type: Function
		},
		/**
		 * 获取完数据过滤数据的方法
		 */
		filterFunction: Function
	},
	data() {
		return {
			current: 1,
			options: [],
			canLoadMore: true
		}
	},
	created() {
		this.getOptions()
	},
	methods: {
		async getOptions() {
			const res = await this.fetchFunction({
				current: this.current
			})
			this.options = this.filterFunction ? this.filterFunction(res.records) : res.records
		}
	}
}
</script>
<style lang="scss" scoped>
.input {
}
</style>
